﻿<cfsilent>
<cfscript>

		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
	
		/*学院列表*/
				
		sql = "SELECT 
					count(*) cou_count, 
					b.institute_id, b.institute_name, 
					b.classification 
				FROM t_course a  
					INNER JOIN t_institute b ON b.institute_id = a.institute_id 
				GROUP BY 
					  b.institute_id, b.institute_name, 
					  b.classification 
				ORDER BY 
					  b.institute_name, 
					  b.classification ";
					  
		queryObj = new query( datasource=application.dnsSlave );
		
		rs_ins = queryObj.execute( sql=sql ).getResult();

		event.setArg("pageTitle", "教学运行基础数据 - 课程库系数维护");

		passArgs = structNew();
	
		currentTab = event.getArg("TabID", "labCourse");
		
		if ( rs_ins.recordCount EQ 0 ) {
			currentTab = "labImport";
		}
		
		/* 搜索课程 */
		keyword = event.getArg("Keywords");
		
		rs_search = queryNew("cid");
		
		if ( len(keyword) ) {
										
			sql = "SELECT 
					c.cid,c.course_code,c.course_name
					FROM t_course c
					WHERE 
						c.course_code LIKE :condition 
						OR 
						c.course_name LIKE :condition 
					ORDER BY c.course_name";
					
			queryObj = new query( datasource=application.dnsSlave,maxRows=20 );
			queryObj.addParam( name="condition", value=keyword&"%", cfsqltype="cf_sql_varchar" );
			
			rs_search = queryObj.execute( sql=sql ).getResult();
			
			currentTab = "labSearch";
		}


	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat"> <a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">师资、教学工作量</span></a> </div>
			<div>
				<h2 class="uiHeaderTitle"> <i class="uiHeaderImage img icon16x16 card"></i>课程概况 </h2>
			</div>
		</div>
	</div>
</div>
<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables"> <span <cfif currentTab eq "labCourse">class="active"</cfif> id="labCourse" tabTarget="Course">开课学院概况</span> <span <cfif currentTab eq "labImport">class="active"</cfif> id="labImport" tabTarget="Import">导入工作量设置</span> <span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索</span> </div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				<div id="Course" class="tabContent">
					<cfif rs_ins.recordCount>
						<div class="noticeBlock">
							<h3>开课部门信息</h3>
							<p><span class="img icon16x16 message"></span>这里列出了开课的部门，如你要设定新课程，请进入基础数据模块中的课程建设栏目。</p>
							<hr/>
						</div>
						<div class="clearfix">
							<div class="UICardTable">
                                <cfloop query="rs_ins" >
									<cfset structInsert(passArgs, "DepID", rs_ins.institute_id, true) />
									<dl>
										<dt> 
										<a href="<cfoutput>#buildURL('courseByDepartment', passArgs)#</cfoutput>"> <em class="collection"><!--imgholder--></em>
										<dd>
											<h3><cfoutput>#rs_ins.institute_name#</cfoutput></h3>
											<div><cfoutput>#rs_ins.cou_count#</cfoutput> 门课程</div>
										</dd>
										</a>
										</dt>
									</dl>
								</cfloop>
							</div>
						</div>
						<cfelse>
						<div class="systemNotice">
							<h3><span class="img icon16x16 info"></span>尚未设置课程信息</h3>
							<p>当前您还没有设置课程, 请通过上方的 "批量导入课程数据" 标签快速的构建教学课程库.</p>
						</div>
					</cfif>
				</div>
				<div id="Search" class="tabContent">
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('courseWorkLoad')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						<div class="label"> <b>课程或课程号</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					<cfif rs_search.recordCount>
						<cfset structInsert(passArgs,"Keywords",keyword,true)/>
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="20"></td>
									<td width="80">课程号</td>
									<td width="140">课程</td>
									<td>双语系数</td>
									<td>实践系数</td>
									<td>分配比例</td>
									<td>编制分类</td>
									<td>理论公式</td>
									<td>实践公式</td>
									<td width="20"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_search" >
									<cfset row ++ />
								
                                    <cfset sql = "SELECT c.cid,c.lang_weight,
														   c.prac_weight,c.work_divide,
														   a.type_name,b.fun_id fun_id1,
														   b.fun_name fun_name1,d.fun_id fun_id2,
														   d.fun_name fun_name2 
													FROM t_course_workload c 
														 INNER JOIN t_hr_workload a ON a.hrt = c.hrt 
														 INNER JOIN t_workload_fun b ON b.fun_id = c.theory_fun 
														 INNER JOIN t_workload_fun d ON d.fun_id = c.practice_fun 
													WHERE c.cid = :CourseID " />
                                    
                                    <cfset queryObj = new query( datasource=application.dnsSlave )/>
                                    <cfset queryObj.addParam( name="CourseID", value=rs_search.cid, cfsqltype="cf_sql_varchar" )/>
                                    <cfset rs_CourseWorkLoads = queryObj.execute( sql=sql ).getResult()/>
                                    
									<cfset structInsert(passArgs, "CID", rs_search.cid, true) />
									<tr class="editRows <cfif event.getArg('CID') eq rs_search.cid> lastEdited</cfif>" rowid="<cfoutput>#rs_search.cid#</cfoutput>">
										<td><cfoutput>#numberFormat(row, '0_')#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_search.course_code#</cfoutput></span></td>
										<td><cfoutput>#rs_search.course_name#</cfoutput></td>
										<td><cfif rs_CourseWorkLoads.recordCount>
												<cfoutput>#rs_CourseWorkLoads["lang_weight"][1]#</cfoutput>
											</cfif></td>
										<td><cfif rs_CourseWorkLoads.recordCount>
												<cfoutput>#rs_CourseWorkLoads["prac_weight"][1]#</cfoutput>
											</cfif></td>
										<td><cfif rs_CourseWorkLoads.recordCount>
												<cfoutput>#rs_CourseWorkLoads["work_divide"][1]#</cfoutput>
											</cfif></td>
										<td><cfif rs_CourseWorkLoads.recordCount>
												<cfoutput>#rs_CourseWorkLoads["type_name"][1]#</cfoutput>
												<cfelse>
												未设置
											</cfif></td>
										<td><cfif rs_CourseWorkLoads.recordCount>
												<cfoutput>#rs_CourseWorkLoads["fun_name1"][1]#</cfoutput>
												<cfelse>
												未设置
											</cfif></td>
										<td><cfif rs_CourseWorkLoads.recordCount>
												<cfoutput>#rs_CourseWorkLoads["fun_name2"][1]#</cfoutput>
												<cfelse>
												未设置
											</cfif></td>
										<td><a href="<cfoutput>#BuildURL("courseWorkLoadSetting",passArgs)#</cfoutput>" class="stat edit"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					</cfif>
				</div>
				<div id="Import" class="tabContent" style="display: block;">
					<div class="noticeBlock">
						<h3>导入课程教学工作量计算系数</h3>
						<p><span class="img icon16x16 message"></span>请严格按照如下的数据模板在电子表格文件中录入课程与系数数据. 点击<a href="<cfoutput>#BuildURL("templateWorkLoad")#</cfoutput>">下载导入模板</a>, 在录入信息时请勿更改第一行表头内容.</p>
						<hr>
						<table>
							<tbody>
								<tr>
									<td>课程号</td>
									<td>课程名称</td>
									<td>双语系数</td>
									<td>实践系数</td>
									<td>主讲工作量权重量比 </td>
									<td>第二主讲工作量权重量比 </td>
									<td>助教工作量权重量比 </td>
									<td>编制分类 </td>
									<td>理论工作量计算公式 </td>
									<td>实践工作量计算公式 </td>
								</tr>
								<tr>
									<td>1000001</td>
									<td>大学物理</td>
									<td>2</td>
									<td>3</td>
									<td>4</td>
									<td>4</td>
									<td>3</td>
									<td>公共类</td>
									<td>两课理论课</td>
									<td>学年体育课</td>
								</tr>
							</tbody>
						</table>
					</div>
					<form target="output" onsubmit="javascript:return processVerfiyForm('formImport');" id="formImport" class="formWrapper" method="post" enctype="multipart/form-data" action="<cfoutput>#BuildURL("importWorkLoad")#</cfoutput>">
						<div class="label"> <span class="req">*</span><b>导入数据文件</b>
							<input name="upload" id="upload" type="file" verification="required">
						</div>
						<div class="lable">
							<input id="importTrigger" class="button" type="submit" value="导入计算系数">
						</div>
					</form>
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$(document).ready(function() {
							$("#importTrigger").click(function(){
								$("#output").attr("src","about:blank").removeClass("hidden_elem");
							});
						});
						// -->
						//]]>
					</script>
					<iframe name="output" id="output" class="UIframeBox hidden_elem" src="about:blank" frameborder="0"></iframe>
				</div>
			</div>
		</li>
	</ul>
</div>
